<?php

$activity = $this->context->activity;
$this->title = $activity->title;

use yii\helpers\Html;

?>

<style>

</style>
<?= \frontend\widgets\Swiper::widget(['model' => $activity]) ?>
<div class="container-fluid">
    <div class="r4_card content">
        <p class="main-font-color p_title"><?= Yii::t('app.c2', 'Activity Introduction') ?></p>
        <?= $activity->content ?>
    </div>
</div>

<script type="text/javascript">
    wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
        //shareData 参数记得为字符串类型
        var shareData = {
            title: '<?= $activity->title ?>',
            desc: '<?= Html::encode($activity->content) ?>',//这里请特别注意是要去除html
            link: '<?= Yii::$app->request->hostInfo . Yii::$app->request->url ?>',//域名必须JS安全域名
            imgUrl: '<?= $activity->getThumbnailUrl() ?>',
            success: function () {

            },
            cancel: function () {
                console.log('cancel')
            }
        };

        if (wx.onMenuShareAppMessage) { //微信文档中提到这两个接口即将弃用，故判断
            wx.onMenuShareAppMessage(shareData);//1.0 分享到朋友
            wx.onMenuShareTimeline(shareData);//1.0分享到朋友圈
        } else {
            wx.updateAppMessageShareData(shareData);//1.4 分享到朋友
            wx.updateTimelineShareData(shareData);//1.4分享到朋友圈
        }

    });
</script>